package com.wsoft.bpm.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * 工作流通用mapper
 *
 * @Author zhonglj
 * @Date 2024-10-09 9:56
 */
public interface BpmActivitiMapper {
    /**
     * 更新工作流状态
     *
     * @param tableName
     * @param statusColumn
     * @param approveStatus
     * @param businessKeyColumn
     * @param businessKey
     * @return int
     * @author zhonglj
     * @date 2024-10-09 10:08
     **/
    int updateApproveStatus(@Param("tableName") String tableName,
                            @Param("statusColumn") String statusColumn,
                            @Param("approveStatus") int approveStatus,
                            @Param("businessKeyColumn") String businessKeyColumn,
                            @Param("businessKey") String businessKey);

    /**
     * 查询业务表工作流状态
     *
     * @param tableName
     * @param statusColumn
     * @param businessKeyColumn
     * @param businessKey
     * @return int
     * @author zhonglj
     * @date 2024/12/3 15:04
     **/
    int getApproveStatus(@Param("tableName") String tableName,
                         @Param("statusColumn") String statusColumn,
                         @Param("businessKeyColumn") String businessKeyColumn,
                         @Param("businessKey") String businessKey);

    /**
     * 查询指定表主键字段
     *
     * @param tableName
     * @param tableSchema
     * @return java.lang.String
     * @author zhonglj
     * @date 2024-10-17 17:11
     **/
    String selectPrimaryKey(@Param("tableName") String tableName, @Param("tableSchema") String tableSchema);

    /**
     * 通过businessKey获取主键值
     *
     * @param tableName
     * @param idColumn
     * @param businessKeyColumn
     * @param businessKey
     * @return java.lang.String
     * @author zhonglj
     * @date 2024-10-19 9:59
     **/
    String getKeyColumnVal(@Param("tableName") String tableName,
                           @Param("idColumn") String idColumn,
                           @Param("businessKeyColumn") String businessKeyColumn,
                           @Param("businessKey") String businessKey);

    /**
     * 手动更新历史任务
     *
     * @param taskId
     * @param procInstId
     * @return int
     * @author zhonglj
     * @date 2024/12/6 9:22
     **/
    @Update("UPDATE `act_hi_taskinst` SET PROC_INST_ID_=#{procInstId},PROC_DEF_ID_=#{procDefId},EXECUTION_ID_=#{executionId},TASK_DEF_KEY_=#{taskDefKey} WHERE ID_ = #{taskId}")
    int updateHiTaskProcInstId(String taskId, String procInstId, String procDefId, String executionId, String taskDefKey);
}
